package com.bjpowernode.crm.web.advice;

import com.bjpowernode.crm.excepetion.LoginException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

//全局异常处理
@ControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler(LoginException.class)
    @ResponseBody
    public Map loginException(Exception e){
        return new HashMap(){
            {
                put("success",false);
                put("msg",e.getMessage());
            }
        };
    }
}
